﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AcademySystem.DAL;

namespace AcademySystem.Service.DTO
{
    public class CourseDTO
    {
        public int CourseId { get; set; }
        public string Title { get; set; }
        public string Information { get; set; }
        public int SubscribersCount { get; set; }
        public int StartDay { get; set; }
        public string StartMonth { get; set; }
        public int EndDay { get; set; }
        public string EndMonth { get; set; }

        public static CourseDTO CreateCourseDTO(Course course)
        {
            CourseDTO courseDto = new CourseDTO()
            {
                CourseId = course.CourseID,
                Title = course.Title,
                Information = course.Information,
                SubscribersCount = course.Subscriptions.Count,
                StartDay = course.StartDate.Day,
                StartMonth = course.StartDate.ToString("MMM"),
                EndDay = course.EndDate.Day,
                EndMonth = course.EndDate.ToString("MMM")
            };
            return courseDto;
        }
    }
}